< previous page page_400 next page >

Page 400
typedef struct _ENUM_SERVICE_STATUS { // ess
    LPTSTR lpServiceName;
    LPTSTR lpDisplayName;
    SERVICE_STATUS ServiceStatus;
} ENUM_SERVICE_STATUS, *LPENUM_SERVICE_STATUS;

 typedef struct _SERVICE_STATUS { // ss
    DWORD dwServiceType;
    DWORD dwCurrentState;
    DWORD dwControlsAccepted;
    DWORD dwWin32ExitCode;
    DWORD dwServiceSpecificExitCode;
    DWORD dwCheckPoint;
    DWORD dwWaitHint;
} SERVICE_STATUS, *LPSERVICE_STATUS;
The lpServiceName string in the ENUM_SERVICE_STATUS structure contains the service name. The lpDisplayname string contains the name displayed to users.
The Service Control Manager supports other functions, but they aren't necessary for the task at hand.
Service Functions
Once you've opened a service, there are a number of operations you can perform on the service using API functions. For our purposes, you only need to be concerned with three of these functions.
1. The StartService function is used to start a service and is defined as follows:
7017a6ead0e3c4111b47a554df321e9f.gif
BOOL StartService(
    SC_HANDLE hService,               // handle of service
    DWORD dwNumServiceArgs,           // number of arguments
    LPCTSTR *lpServiceArgVectors      // address of array of argument
                                      string pointers
   );
The function allows you to pass arguments to the service, but most services don't take arguments when startingcertainly not the services that concern us. So the dwNumServiceArgs and lpServiceArgVectors parameters can both be set to NULL.

 
< previous page page_400 next page >